package com.puman.watchtrade.fragment.personal.adapter;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.puman.watchtrade.R;
import com.puman.watchtrade.fragment.info.model.InfoDatas;
import com.puman.watchtrade.fragment.personal.model.SystemMsgs;
import com.puman.watchtrade.util.ImageDownloader;
import com.puman.watchtrade.util.OnImageDownload;

public class SystemMsgListViewAdapter extends BaseAdapter{

	private LayoutInflater listContainer; // ��ͼ����
	private View view;
	private Activity activity;
	private ImageDownloader mDownloader;
	private SystemMsgs systemMsgs = new SystemMsgs();

	public final class ListItemView {
		public TextView title;
		public TextView datetime;
		public ImageView image;
	}

	public SystemMsgListViewAdapter(Activity activity, SystemMsgs systemMsgs ) {
		this.activity = activity;
		this.systemMsgs = systemMsgs;
		listContainer = LayoutInflater.from(activity);
		// TODO Auto-generated constructor stub
	}

	
	/**
	 */
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		final ListItemView listItemView;
		final int selectID = position;
		if (convertView == null) {
			listItemView = new ListItemView();
			convertView = listContainer.inflate(R.layout.system_msg_item, null);
			listItemView.title = (TextView) convertView.findViewById(R.id.info_title);
			listItemView.datetime = (TextView) convertView.findViewById(R.id.datetime);
			listItemView.image = (ImageView) convertView.findViewById(R.id.info_item_image);
			convertView.setTag(listItemView);
		} else {
			listItemView = (ListItemView) convertView.getTag();

		}
//		if (systemMsgs.systemMsgList.get(position).getMsg().length() > 20) {
//			listItemView.title.setText(systemMsgs.systemMsgList.get(position).getMsg().substring(0, 20)+"...");
//		}else {
			listItemView.title.setText(systemMsgs.systemMsgList.get(position).getMsg());
//		}
//		listItemView.title.setText(systemMsgs.systemMsgList.get(position).getTitle());
		listItemView.datetime.setText(systemMsgs.systemMsgList.get(position).getDatetime());

		return convertView;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return systemMsgs.systemMsgList.size();
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub

		return 0;
	}

}